using System;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace WebChart
{
	public class AreaChart : Chart
	{
		// Methods
		public AreaChart()
		{
		}

		public AreaChart(ChartPointCollection data) : base(data)
		{
		}

		public AreaChart(ChartPointCollection data, Color color) : base(data, color)
		{
		}

		public override void Render(Graphics graphics, int width, int height)
		{
			ChartEngine engine = base.Engine;
			float scaleX = engine.scaleX;
			float scaleY = engine.scaleY;
			Point[] pointArray = new Point[base.Data.Count + 2];
			GraphicsPath path = new GraphicsPath();
			bool flag = (base.shadow != null) && base.Shadow.Visible;
			GraphicsPath path2 = null;
			if (flag)
			{
				path2 = new GraphicsPath();
			}
			int index = 0;
			float num4 = scaleX / 2f;
			pointArray[index++] = new Point((int) num4, 0);
			foreach (ChartPoint point in base.Data)
			{
				int y = (int) (point.yvalue * scaleY);
				int x = (int) ((index * scaleX) - num4);
				if (base.showLineMarkers)
				{
					base.lineMarker.Render(graphics, x, y);
				}
				pointArray[index] = new Point(x, y);
				if (index > 0)
				{
					if (flag)
					{
						path2.AddLine((int) (pointArray[index - 1].X + base.Shadow.OffsetX), (int) (pointArray[index - 1].Y + base.Shadow.OffsetY), (int) (pointArray[index].X + base.Shadow.OffsetX), (int) (pointArray[index].Y + base.Shadow.OffsetY));
					}
					path.AddLine(pointArray[index - 1], pointArray[index]);
				}
				index++;
			}
			pointArray[index] = new Point(pointArray[index - 1].X, 0);
			path.AddLine(pointArray[index - 1], pointArray[index]);
			if (flag)
			{
				SolidBrush brush = new SolidBrush(base.Shadow.Color);
				path2.AddLine(pointArray[index - 1].X, pointArray[index - 1].Y, pointArray[index].X, pointArray[index].Y);
				graphics.FillPath(brush, path2);
				brush.Dispose();
			}
			Brush brush2 = base.Fill.GetBrush(graphics);
			graphics.FillPath(brush2, path);
			brush2.Dispose();
			Pen pen = base.Line.GetPen(graphics);
			graphics.DrawPath(pen, path);
			pen.Dispose();
			if (base.dataLabels.visible)
			{
				base.RenderDataLabels(graphics);
			}
		}
	}
}
